5.7. Button system in the button procedure

Here is an example of a POPUP panel with its own button system:

//--- Button procedure: Temperature Dependence
void far bpTdep(void)
{
 .
 .
 phase = 11;    // No measurement - idle backgr. proc
butsystem bsTdep; // new button system is declared

// Here go declarations of Objects on the TDep panel
 .
 .
        //---------------- Buttons ------
butgrp gr1( .., .., .., 20);
// bpStartTdep sets phase=1 to start the measurement
  button butStart("Start measurement",'S','s',bpStartTdep,SMALL_FONT,4);
// bpStopTdep sets phase=10 to stop the measurement
  button butStop("stoP measurement",'P','p',bpStopTdep,SMALL_FONT,4);

// pbdTdependence panel (Board class) is declared in the main()
// with zero size. Set now its real size:
 pbdTdependence->ChangeSize(axmax-ax0,butStop.ymax-ay0);

//--- Paint whole panel
 pbdTdependence->Paint();
 .
 .
 gr1.Paint();

 bsTdep.NextButton();   // light on button
 do // about TdepBackgr look at sect. 5.5
  bsTdep.Loop(TdepBackgr);
 while(measInProgress);

 pbdTdependence->Remove();   // remove POPUP panel from the screen
 pbdTdependence->MkActive(); // now you can drag the panel from the
                             // Main Loop
}